﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.Collections.Specialized;
using Microsoft.ComponentModel;

namespace Microsoft.Collections.ObjectModel
{
    public partial class ObservableCollectionEx<T> : ObservableCollection<T>, INotifyCollectionItemChanged, INotifyObject
    {
        public ObservableCollectionEx()
        {
        }
        
        public ObservableCollectionEx(List<T> collection) 
        {
            if (collection == null)
                throw new ArgumentNullException("List<T> collection");
          
            CopyFrom(collection);
        }

        public ObservableCollectionEx(IEnumerable<T> collection)
        {
            if (collection == null)
                throw new ArgumentNullException("IEnumerable<T> collection");
            CopyFrom(collection);
        }
        
        void CopyFrom(IEnumerable<T> collection)
        {
            if (collection == null)
                return;
            if (base.Items == null)
                return;

            foreach (T item in collection)
                base.Items.Add(item);
        }
    }
}